package com.mx.tool.form.factory;

import com.intellij.ui.JBColor;
import com.mx.tool.form.window.encryption.Base64Window;
import com.mx.tool.form.window.encryption.EncryptionWindow;
import com.mx.tool.form.window.encryption.HashWindow;
import com.mx.tool.form.window.zh.*;

import javax.swing.*;

/**
 * @Author: 徐建鹏.
 * @create: 2021-11-10 08:51
 * @Description:
 */
public class ZhFactory {

    private final static JsonToolWindow JSON_TOOL_WINDOW;
    private final static JsonToEntityWindow JSON_TO_ENTITY_WINDOW;
    private final static JwtWindow JWT_WINDOW;
    private final static PinyinWindow PINYIN_WINDOW;
    private final static TimeUtcWindow TIME_UTC_WINDOW;
    private final static UnicodeWindow UNICODE_WINDOW;
    private final static UrlWindow URL_WINDOW;
    private final static VarNameWindow VAR_NAME_WINDOW;

    static {
        JSON_TOOL_WINDOW = new JsonToolWindow();
        JSON_TO_ENTITY_WINDOW = new JsonToEntityWindow();
        JWT_WINDOW = new JwtWindow();
        PINYIN_WINDOW = new PinyinWindow();
        TIME_UTC_WINDOW = new TimeUtcWindow();
        UNICODE_WINDOW = new UnicodeWindow();
        URL_WINDOW = new UrlWindow();
        VAR_NAME_WINDOW = new VarNameWindow();
    }


    /**
     * 添加监听
     * @param jsonToolButton
     * @param urlButton
     * @param timeUtcButton
     * @param hzToPyButton
     * @param unicodeButton
     * @param jsonToEntityButton
     * @param varNameButton
     * @param jwtButton
     * @param zhPanel
     */
    public static void addActionListeners(JButton jsonToolButton,JButton urlButton,JButton timeUtcButton,JButton hzToPyButton,JButton unicodeButton,
                                          JButton jsonToEntityButton,JButton varNameButton,JButton jwtButton,JPanel zhPanel) {
        JPanel jsonToolJPanel = JSON_TOOL_WINDOW.getContent();
        JPanel jsonToEntityJPanel = JSON_TO_ENTITY_WINDOW.getContent();
        JPanel jwtWindowJPanel = JWT_WINDOW.getContent();
        JPanel pinyinWindowJPanel = PINYIN_WINDOW.getContent();
        JPanel timeUtcWindowJPanel = TIME_UTC_WINDOW.getContent();
        JPanel unicodeWindowJPanel = UNICODE_WINDOW.getContent();
        JPanel urlWindowJPanel = URL_WINDOW.getContent();
        JPanel varNameJPanel = VAR_NAME_WINDOW.getContent();
        zhPanel.add("jsonToolJPanel", jsonToolJPanel);
        zhPanel.add("jsonToEntityJPanel", jsonToEntityJPanel);
        zhPanel.add("jwtWindowJPanel", jwtWindowJPanel);
        zhPanel.add("pinyinWindowJPanel", pinyinWindowJPanel);
        zhPanel.add("timeUtcWindowJPanel", timeUtcWindowJPanel);
        zhPanel.add("unicodeWindowJPanel", unicodeWindowJPanel);
        zhPanel.add("urlWindowJPanel", urlWindowJPanel);
        zhPanel.add("varNameJPanel", varNameJPanel);
        jsonToolButton.setForeground(JBColor.GREEN);
        jsonToolButton(jsonToolButton, urlButton, timeUtcButton, hzToPyButton, unicodeButton, jsonToEntityButton,varNameButton, jwtButton,
                jsonToolJPanel,jsonToEntityJPanel,jwtWindowJPanel,pinyinWindowJPanel,timeUtcWindowJPanel,unicodeWindowJPanel,urlWindowJPanel,varNameJPanel);
        urlButton(jsonToolButton, urlButton, timeUtcButton, hzToPyButton, unicodeButton, jsonToEntityButton,varNameButton, jwtButton,
                jsonToolJPanel,jsonToEntityJPanel,jwtWindowJPanel,pinyinWindowJPanel,timeUtcWindowJPanel,unicodeWindowJPanel,urlWindowJPanel,varNameJPanel);
        timeUtcButton(jsonToolButton, urlButton, timeUtcButton, hzToPyButton, unicodeButton, jsonToEntityButton,varNameButton, jwtButton,
                jsonToolJPanel,jsonToEntityJPanel,jwtWindowJPanel,pinyinWindowJPanel,timeUtcWindowJPanel,unicodeWindowJPanel,urlWindowJPanel,varNameJPanel);
        hzToPyButton(jsonToolButton, urlButton, timeUtcButton, hzToPyButton, unicodeButton, jsonToEntityButton,varNameButton, jwtButton,
                jsonToolJPanel,jsonToEntityJPanel,jwtWindowJPanel,pinyinWindowJPanel,timeUtcWindowJPanel,unicodeWindowJPanel,urlWindowJPanel,varNameJPanel);
        unicodeButton(jsonToolButton, urlButton, timeUtcButton, hzToPyButton, unicodeButton, jsonToEntityButton,varNameButton, jwtButton,
                jsonToolJPanel,jsonToEntityJPanel,jwtWindowJPanel,pinyinWindowJPanel,timeUtcWindowJPanel,unicodeWindowJPanel,urlWindowJPanel,varNameJPanel);
        jsonToEntityButton(jsonToolButton, urlButton, timeUtcButton, hzToPyButton, unicodeButton, jsonToEntityButton,varNameButton, jwtButton,
                jsonToolJPanel,jsonToEntityJPanel,jwtWindowJPanel,pinyinWindowJPanel,timeUtcWindowJPanel,unicodeWindowJPanel,urlWindowJPanel,varNameJPanel);
        varNameButton(jsonToolButton, urlButton, timeUtcButton, hzToPyButton, unicodeButton, jsonToEntityButton,varNameButton, jwtButton,
                jsonToolJPanel,jsonToEntityJPanel,jwtWindowJPanel,pinyinWindowJPanel,timeUtcWindowJPanel,unicodeWindowJPanel,urlWindowJPanel,varNameJPanel);
        jwtButton(jsonToolButton, urlButton, timeUtcButton, hzToPyButton, unicodeButton, jsonToEntityButton,varNameButton, jwtButton,
                jsonToolJPanel,jsonToEntityJPanel,jwtWindowJPanel,pinyinWindowJPanel,timeUtcWindowJPanel,unicodeWindowJPanel,urlWindowJPanel,varNameJPanel);

    }

    private static void jsonToolButton(JButton jsonToolButton,JButton urlButton,JButton timeUtcButton,JButton hzToPyButton,JButton unicodeButton,
                                   JButton jsonToEntityButton,JButton varNameButton,JButton jwtButton,
                                       JPanel jsonToolJPanel, JPanel jsonToEntityJPanel,JPanel jwtWindowJPanel,JPanel pinyinWindowJPanel,
                                       JPanel timeUtcWindowJPanel,JPanel unicodeWindowJPanel,JPanel urlWindowJPanel,JPanel varNameJPanel) {
        jsonToolButton.addActionListener(e -> {
            jsonToEntityJPanel.setVisible(false);
            jsonToEntityButton.setForeground(JBColor.BLACK);
            jwtWindowJPanel.setVisible(false);
            jwtButton.setForeground(JBColor.BLACK);
            pinyinWindowJPanel.setVisible(false);
            hzToPyButton.setForeground(JBColor.BLACK);
            timeUtcWindowJPanel.setVisible(false);
            timeUtcButton.setForeground(JBColor.BLACK);
            unicodeWindowJPanel.setVisible(false);
            unicodeButton.setForeground(JBColor.BLACK);
            urlWindowJPanel.setVisible(false);
            urlButton.setForeground(JBColor.BLACK);
            varNameJPanel.setVisible(false);
            varNameButton.setForeground(JBColor.BLACK);
            jsonToolJPanel.setVisible(true);
            jsonToolButton.setForeground(JBColor.GREEN);
        });
    }

    private static void urlButton(JButton jsonToolButton,JButton urlButton,JButton timeUtcButton,JButton hzToPyButton,JButton unicodeButton,
                                       JButton jsonToEntityButton,JButton varNameButton,JButton jwtButton,
                                       JPanel jsonToolJPanel, JPanel jsonToEntityJPanel,JPanel jwtWindowJPanel,JPanel pinyinWindowJPanel,
                                       JPanel timeUtcWindowJPanel,JPanel unicodeWindowJPanel,JPanel urlWindowJPanel,JPanel varNameJPanel) {
        urlButton.addActionListener(e -> {
            jsonToEntityJPanel.setVisible(false);
            jsonToEntityButton.setForeground(JBColor.BLACK);
            jwtWindowJPanel.setVisible(false);
            jwtButton.setForeground(JBColor.BLACK);
            pinyinWindowJPanel.setVisible(false);
            hzToPyButton.setForeground(JBColor.BLACK);
            timeUtcWindowJPanel.setVisible(false);
            timeUtcButton.setForeground(JBColor.BLACK);
            unicodeWindowJPanel.setVisible(false);
            unicodeButton.setForeground(JBColor.BLACK);
            varNameJPanel.setVisible(false);
            varNameButton.setForeground(JBColor.BLACK);
            jsonToolJPanel.setVisible(false);
            jsonToolButton.setForeground(JBColor.BLACK);
            urlWindowJPanel.setVisible(true);
            urlButton.setForeground(JBColor.GREEN);
        });
    }

    private static void timeUtcButton(JButton jsonToolButton,JButton urlButton,JButton timeUtcButton,JButton hzToPyButton,JButton unicodeButton,
                                  JButton jsonToEntityButton,JButton varNameButton,JButton jwtButton,
                                  JPanel jsonToolJPanel, JPanel jsonToEntityJPanel,JPanel jwtWindowJPanel,JPanel pinyinWindowJPanel,
                                  JPanel timeUtcWindowJPanel,JPanel unicodeWindowJPanel,JPanel urlWindowJPanel,JPanel varNameJPanel) {
        timeUtcButton.addActionListener(e -> {
            jsonToEntityJPanel.setVisible(false);
            jsonToEntityButton.setForeground(JBColor.BLACK);
            jwtWindowJPanel.setVisible(false);
            jwtButton.setForeground(JBColor.BLACK);
            pinyinWindowJPanel.setVisible(false);
            hzToPyButton.setForeground(JBColor.BLACK);
            unicodeWindowJPanel.setVisible(false);
            unicodeButton.setForeground(JBColor.BLACK);
            varNameJPanel.setVisible(false);
            varNameButton.setForeground(JBColor.BLACK);
            jsonToolJPanel.setVisible(false);
            jsonToolButton.setForeground(JBColor.BLACK);
            urlWindowJPanel.setVisible(false);
            urlButton.setForeground(JBColor.BLACK);
            timeUtcWindowJPanel.setVisible(true);
            timeUtcButton.setForeground(JBColor.GREEN);
        });
    }

    private static void hzToPyButton(JButton jsonToolButton,JButton urlButton,JButton timeUtcButton,JButton hzToPyButton,JButton unicodeButton,
                                      JButton jsonToEntityButton,JButton varNameButton,JButton jwtButton,
                                      JPanel jsonToolJPanel, JPanel jsonToEntityJPanel,JPanel jwtWindowJPanel,JPanel pinyinWindowJPanel,
                                      JPanel timeUtcWindowJPanel,JPanel unicodeWindowJPanel,JPanel urlWindowJPanel,JPanel varNameJPanel) {
        hzToPyButton.addActionListener(e -> {
            jsonToEntityJPanel.setVisible(false);
            jsonToEntityButton.setForeground(JBColor.BLACK);
            jwtWindowJPanel.setVisible(false);
            jwtButton.setForeground(JBColor.BLACK);
            unicodeWindowJPanel.setVisible(false);
            unicodeButton.setForeground(JBColor.BLACK);
            varNameJPanel.setVisible(false);
            varNameButton.setForeground(JBColor.BLACK);
            jsonToolJPanel.setVisible(false);
            jsonToolButton.setForeground(JBColor.BLACK);
            urlWindowJPanel.setVisible(false);
            urlButton.setForeground(JBColor.BLACK);
            timeUtcWindowJPanel.setVisible(false);
            timeUtcButton.setForeground(JBColor.BLACK);
            pinyinWindowJPanel.setVisible(true);
            hzToPyButton.setForeground(JBColor.GREEN);
        });
    }


    private static void unicodeButton(JButton jsonToolButton,JButton urlButton,JButton timeUtcButton,JButton hzToPyButton,JButton unicodeButton,
                                     JButton jsonToEntityButton,JButton varNameButton,JButton jwtButton,
                                     JPanel jsonToolJPanel, JPanel jsonToEntityJPanel,JPanel jwtWindowJPanel,JPanel pinyinWindowJPanel,
                                     JPanel timeUtcWindowJPanel,JPanel unicodeWindowJPanel,JPanel urlWindowJPanel,JPanel varNameJPanel) {
        unicodeButton.addActionListener(e -> {
            jsonToEntityJPanel.setVisible(false);
            jsonToEntityButton.setForeground(JBColor.BLACK);
            jwtWindowJPanel.setVisible(false);
            jwtButton.setForeground(JBColor.BLACK);
            varNameJPanel.setVisible(false);
            varNameButton.setForeground(JBColor.BLACK);
            jsonToolJPanel.setVisible(false);
            jsonToolButton.setForeground(JBColor.BLACK);
            urlWindowJPanel.setVisible(false);
            urlButton.setForeground(JBColor.BLACK);
            timeUtcWindowJPanel.setVisible(false);
            timeUtcButton.setForeground(JBColor.BLACK);
            pinyinWindowJPanel.setVisible(false);
            hzToPyButton.setForeground(JBColor.BLACK);
            unicodeWindowJPanel.setVisible(true);
            unicodeButton.setForeground(JBColor.GREEN);
        });
    }

    private static void jsonToEntityButton(JButton jsonToolButton,JButton urlButton,JButton timeUtcButton,JButton hzToPyButton,JButton unicodeButton,
                                      JButton jsonToEntityButton,JButton varNameButton,JButton jwtButton,
                                      JPanel jsonToolJPanel, JPanel jsonToEntityJPanel,JPanel jwtWindowJPanel,JPanel pinyinWindowJPanel,
                                      JPanel timeUtcWindowJPanel,JPanel unicodeWindowJPanel,JPanel urlWindowJPanel,JPanel varNameJPanel) {
        jsonToEntityButton.addActionListener(e -> {
            jwtWindowJPanel.setVisible(false);
            jwtButton.setForeground(JBColor.BLACK);
            varNameJPanel.setVisible(false);
            varNameButton.setForeground(JBColor.BLACK);
            jsonToolJPanel.setVisible(false);
            jsonToolButton.setForeground(JBColor.BLACK);
            urlWindowJPanel.setVisible(false);
            urlButton.setForeground(JBColor.BLACK);
            timeUtcWindowJPanel.setVisible(false);
            timeUtcButton.setForeground(JBColor.BLACK);
            pinyinWindowJPanel.setVisible(false);
            hzToPyButton.setForeground(JBColor.BLACK);
            unicodeWindowJPanel.setVisible(false);
            unicodeButton.setForeground(JBColor.BLACK);
            jsonToEntityJPanel.setVisible(true);
            jsonToEntityButton.setForeground(JBColor.GREEN);
        });
    }

    private static void varNameButton(JButton jsonToolButton,JButton urlButton,JButton timeUtcButton,JButton hzToPyButton,JButton unicodeButton,
                                           JButton jsonToEntityButton,JButton varNameButton,JButton jwtButton,
                                           JPanel jsonToolJPanel, JPanel jsonToEntityJPanel,JPanel jwtWindowJPanel,JPanel pinyinWindowJPanel,
                                           JPanel timeUtcWindowJPanel,JPanel unicodeWindowJPanel,JPanel urlWindowJPanel,JPanel varNameJPanel) {
        varNameButton.addActionListener(e -> {
            jwtWindowJPanel.setVisible(false);
            jwtButton.setForeground(JBColor.BLACK);
            jsonToolJPanel.setVisible(false);
            jsonToolButton.setForeground(JBColor.BLACK);
            urlWindowJPanel.setVisible(false);
            urlButton.setForeground(JBColor.BLACK);
            timeUtcWindowJPanel.setVisible(false);
            timeUtcButton.setForeground(JBColor.BLACK);
            pinyinWindowJPanel.setVisible(false);
            hzToPyButton.setForeground(JBColor.BLACK);
            unicodeWindowJPanel.setVisible(false);
            unicodeButton.setForeground(JBColor.BLACK);
            jsonToEntityJPanel.setVisible(false);
            jsonToEntityButton.setForeground(JBColor.BLACK);
            varNameJPanel.setVisible(true);
            varNameButton.setForeground(JBColor.GREEN);
        });
    }

    private static void jwtButton(JButton jsonToolButton,JButton urlButton,JButton timeUtcButton,JButton hzToPyButton,JButton unicodeButton,
                                      JButton jsonToEntityButton,JButton varNameButton,JButton jwtButton,
                                      JPanel jsonToolJPanel, JPanel jsonToEntityJPanel,JPanel jwtWindowJPanel,JPanel pinyinWindowJPanel,
                                      JPanel timeUtcWindowJPanel,JPanel unicodeWindowJPanel,JPanel urlWindowJPanel,JPanel varNameJPanel) {
        jwtButton.addActionListener(e -> {
            jsonToolJPanel.setVisible(false);
            jsonToolButton.setForeground(JBColor.BLACK);
            urlWindowJPanel.setVisible(false);
            urlButton.setForeground(JBColor.BLACK);
            timeUtcWindowJPanel.setVisible(false);
            timeUtcButton.setForeground(JBColor.BLACK);
            pinyinWindowJPanel.setVisible(false);
            hzToPyButton.setForeground(JBColor.BLACK);
            unicodeWindowJPanel.setVisible(false);
            unicodeButton.setForeground(JBColor.BLACK);
            jsonToEntityJPanel.setVisible(false);
            jsonToEntityButton.setForeground(JBColor.BLACK);
            varNameJPanel.setVisible(false);
            varNameButton.setForeground(JBColor.BLACK);
            jwtWindowJPanel.setVisible(true);
            jwtButton.setForeground(JBColor.GREEN);
        });
    }


}
